/**
 */
package sdmakerz_v1.coresyntax.sDMakerV1.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import sdmakerz_v1.coresyntax.sDMakerV1.Call;
import sdmakerz_v1.coresyntax.sDMakerV1.CombinableDiagramElement;
import sdmakerz_v1.coresyntax.sDMakerV1.Expression;
import sdmakerz_v1.coresyntax.sDMakerV1.SDMakerV1Package;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Call</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link sdmakerz_v1.coresyntax.sDMakerV1.impl.CallImpl#getCaller <em>Caller</em>}</li>
 *   <li>{@link sdmakerz_v1.coresyntax.sDMakerV1.impl.CallImpl#getCalled <em>Called</em>}</li>
 *   <li>{@link sdmakerz_v1.coresyntax.sDMakerV1.impl.CallImpl#getName <em>Name</em>}</li>
 *   <li>{@link sdmakerz_v1.coresyntax.sDMakerV1.impl.CallImpl#getParams <em>Params</em>}</li>
 *   <li>{@link sdmakerz_v1.coresyntax.sDMakerV1.impl.CallImpl#getNested_calls <em>Nested calls</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class CallImpl extends CombinableDiagramElementImpl implements Call
{
  /**
   * The default value of the '{@link #getCaller() <em>Caller</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getCaller()
   * @generated
   * @ordered
   */
  protected static final String CALLER_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getCaller() <em>Caller</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getCaller()
   * @generated
   * @ordered
   */
  protected String caller = CALLER_EDEFAULT;

  /**
   * The default value of the '{@link #getCalled() <em>Called</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getCalled()
   * @generated
   * @ordered
   */
  protected static final String CALLED_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getCalled() <em>Called</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getCalled()
   * @generated
   * @ordered
   */
  protected String called = CALLED_EDEFAULT;

  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected String name = NAME_EDEFAULT;

  /**
   * The cached value of the '{@link #getParams() <em>Params</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getParams()
   * @generated
   * @ordered
   */
  protected EList<Expression> params;

  /**
   * The cached value of the '{@link #getNested_calls() <em>Nested calls</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getNested_calls()
   * @generated
   * @ordered
   */
  protected EList<CombinableDiagramElement> nested_calls;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected CallImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return SDMakerV1Package.Literals.CALL;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getCaller()
  {
    return caller;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setCaller(String newCaller)
  {
    String oldCaller = caller;
    caller = newCaller;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, SDMakerV1Package.CALL__CALLER, oldCaller, caller));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getCalled()
  {
    return called;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setCalled(String newCalled)
  {
    String oldCalled = called;
    called = newCalled;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, SDMakerV1Package.CALL__CALLED, oldCalled, called));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getName()
  {
    return name;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, SDMakerV1Package.CALL__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Expression> getParams()
  {
    if (params == null)
    {
      params = new EObjectContainmentEList<Expression>(Expression.class, this, SDMakerV1Package.CALL__PARAMS);
    }
    return params;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<CombinableDiagramElement> getNested_calls()
  {
    if (nested_calls == null)
    {
      nested_calls = new EObjectContainmentEList<CombinableDiagramElement>(CombinableDiagramElement.class, this, SDMakerV1Package.CALL__NESTED_CALLS);
    }
    return nested_calls;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case SDMakerV1Package.CALL__PARAMS:
        return ((InternalEList<?>)getParams()).basicRemove(otherEnd, msgs);
      case SDMakerV1Package.CALL__NESTED_CALLS:
        return ((InternalEList<?>)getNested_calls()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case SDMakerV1Package.CALL__CALLER:
        return getCaller();
      case SDMakerV1Package.CALL__CALLED:
        return getCalled();
      case SDMakerV1Package.CALL__NAME:
        return getName();
      case SDMakerV1Package.CALL__PARAMS:
        return getParams();
      case SDMakerV1Package.CALL__NESTED_CALLS:
        return getNested_calls();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case SDMakerV1Package.CALL__CALLER:
        setCaller((String)newValue);
        return;
      case SDMakerV1Package.CALL__CALLED:
        setCalled((String)newValue);
        return;
      case SDMakerV1Package.CALL__NAME:
        setName((String)newValue);
        return;
      case SDMakerV1Package.CALL__PARAMS:
        getParams().clear();
        getParams().addAll((Collection<? extends Expression>)newValue);
        return;
      case SDMakerV1Package.CALL__NESTED_CALLS:
        getNested_calls().clear();
        getNested_calls().addAll((Collection<? extends CombinableDiagramElement>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case SDMakerV1Package.CALL__CALLER:
        setCaller(CALLER_EDEFAULT);
        return;
      case SDMakerV1Package.CALL__CALLED:
        setCalled(CALLED_EDEFAULT);
        return;
      case SDMakerV1Package.CALL__NAME:
        setName(NAME_EDEFAULT);
        return;
      case SDMakerV1Package.CALL__PARAMS:
        getParams().clear();
        return;
      case SDMakerV1Package.CALL__NESTED_CALLS:
        getNested_calls().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case SDMakerV1Package.CALL__CALLER:
        return CALLER_EDEFAULT == null ? caller != null : !CALLER_EDEFAULT.equals(caller);
      case SDMakerV1Package.CALL__CALLED:
        return CALLED_EDEFAULT == null ? called != null : !CALLED_EDEFAULT.equals(called);
      case SDMakerV1Package.CALL__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case SDMakerV1Package.CALL__PARAMS:
        return params != null && !params.isEmpty();
      case SDMakerV1Package.CALL__NESTED_CALLS:
        return nested_calls != null && !nested_calls.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (caller: ");
    result.append(caller);
    result.append(", called: ");
    result.append(called);
    result.append(", name: ");
    result.append(name);
    result.append(')');
    return result.toString();
  }

} //CallImpl
